const app = getApp()
Page({
  data: {
    imgUrls: [
      'cloud://gtss-2b1812.6774-gtss-2b1812/Swiper/sw1.jpg',
      'cloud://gtss-2b1812.6774-gtss-2b1812/Swiper/sw2.jpg',
      'cloud://gtss-2b1812.6774-gtss-2b1812/Swiper/sw3.jpg',
      'cloud://gtss-2b1812.6774-gtss-2b1812/Swiper/sw4.jpg'
    ],
    xwList: []
  },
  onShow: function() {
    const that = this
    wx.cloud.database({
      env: 'gtss-2b1812'
    }).collection('News').where({
      dept: app.globalData.userDept
    }).limit(20).orderBy('time', 'desc').get({
      success(res) {
        that.setData({
          xwList: res.data
        })
      }
    })
  },
  onReachBottom: function() {
    const that = this
    wx.cloud.database({
      env: 'gtss-2b1812'
    }).collection('News').where({
      dept: app.globalData.userDept
    }).limit(20).skip(that.data.xwList.length).orderBy('time', 'desc').get({
      success(res) {
        that.setData({
          xwList: that.data.xwList.concat(res.data)
        })
      }
    })
  },
  funYl: function(e) {
    wx.previewImage({
      current: e.currentTarget.dataset.imagelist,
      urls: e.currentTarget.dataset.fileidlist
    })
  },
  funYl1: function(e) {
    wx.previewImage({
      current: e.currentTarget.dataset.imagelist,
      urls: [
        'cloud://gtss-2b1812.6774-gtss-2b1812/Swiper/sw1.jpg',
        'cloud://gtss-2b1812.6774-gtss-2b1812/Swiper/sw2.jpg',
        'cloud://gtss-2b1812.6774-gtss-2b1812/Swiper/sw3.jpg',
        'cloud://gtss-2b1812.6774-gtss-2b1812/Swiper/sw4.jpg'
      ]
    })
  }
})